/**
 * @file phonebook.h
 *
 */
#ifndef PHONEBOOK_H
#define PHONEBOOK_H

#ifdef __cplusplus
extern "C" {
#endif

/*********************
 *      INCLUDES
 *********************/

#ifdef LV_CONF_INCLUDE_SIMPLE
#include "lvgl.h"
#include "lv_watch_conf.h"
#else
#include "../../../lvgl/lvgl.h"
#include "../../../lv_watch_conf.h"
#endif

#if USE_LV_WATCH_PHONEBOOK != 0

#if USE_LV_WATCH_VOICE_MSG != 0
#include "../voice_msg/voice_msg.h"
#endif

/*********************
 *      DEFINES
 *********************/
typedef nv_watch_phonebook_info_t phonebook_t;

#define PHONEBOOK_CONTACTS_MAX_NAME_LEN    NV_CONTACTS_MAX_NAME_LEN
#define PHONEBOOK_CONTACTS_MAX_NUMBER_LEN  NV_CONTACTS_MAX_NUMBER_LEN
typedef struct {
    char contact_name[PHONEBOOK_CONTACTS_MAX_NAME_LEN];
    char contact_number[PHONEBOOK_CONTACTS_MAX_NUMBER_LEN];
    const char * img_src;
    const char * img_src_small;
    uint8_t contact_type; /*0:administrator, 1:standby administrator, 2: others*/
} phonebook_contact_t;

/**********************
 *      TYPEDEFS
 **********************/
typedef struct {
    lv_watch_obj_ext_t lv_watch_obj;
    /*New data for this type */
    uint8_t body_padding_inner;
    uint8_t append_width;
    uint8_t cur_img_id;
    phonebook_t * cur_contact;
    lv_ll_t contact_list;
    lv_obj_t * label_phone_name;
    lv_obj_t * label_phone_number;
    lv_obj_t * page_scrl;
    lv_coord_t move_width;
    lv_point_t point_start;
} lv_phonebook_obj_ext_t;

/**********************
 * GLOBAL PROTOTYPES
 **********************/
void phonebook_init(void);
void phonebook_create_btn_event_cb(lv_obj_t * btn, lv_event_t e);
phonebook_contact_t * phonebook_get_contact_info(char * number);
char * phonebook_get_phone_number(uint8_t id); /*[0, NV_WATCH_MAX_CONTACT_NUM - 1]*/
/**********************
 *      MACROS
 **********************/

#endif /*USE_LV_WATCH_PHONEBOOK*/

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /*TIME_H*/
